package ca.kooki.codesnippet.views;

import junit.framework.Assert;

import org.junit.Before;
import org.junit.Test;

import ca.kooki.codesnippet.Activator;
import ca.kooki.codesnippet.CodeSnippet;
import ca.kooki.codesnippet.CodeSnippetRepository;
import ca.kooki.codesnippet.Tag;
import ca.kooki.codesnippet.core.User;

public class StatisticsSummaryViewTest extends SwtTest {

  private StatisticsSummaryView view;
  
  @Before
  public void setUp() throws Exception {
    super.setUp();
    view = new StatisticsSummaryView();
  }
  
  @Test
  public void UpdateTheInnerHtmlOnFocus()
  {
    view.createPartControl(parent);
    Assert.assertEquals(-1, view.innerHtml.indexOf("aforward"));
    
    CodeSnippetRepository repo = Activator.getDefault().getRepository();
    repo.addUser(new User("aforward"));
    
    CodeSnippet snippet = new CodeSnippet("t","k","c");
    Tag tag = new Tag("t2","k2",snippet,"aforward");
    repo.addTag(tag);
    
    view.setFocus();
    Assert.assertEquals(false, view.innerHtml.indexOf("aforward") == -1);
  } 

}
